/**
 * Definition for singly-linked list.
 * struct ListNode {
 *     int val;
 *     ListNode *next;
 *     ListNode() : val(0), next(nullptr) {}
 *     ListNode(int x) : val(x), next(nullptr) {}
 *     ListNode(int x, ListNode *next) : val(x), next(next) {}
 * };
 */
class Solution {
public:
    ListNode* swapPairs(ListNode* head) {
        ListNode *guard=new ListNode(0);
        guard->next=head;
        ListNode *ind0=guard;
        ListNode *ind1=head;
        while(ind1!=NULL&&ind1->next!=NULL){
            ListNode *ind2=ind1->next;
            ListNode *ind3=ind2->next;
            ind0->next=ind1->next;
            ind2->next=ind1;
            ind1->next=ind3;
            ind0=ind1;
            ind1=ind3;
        }
        return guard->next;
    }
};